package com.nbsaas.boot.data.rest.convert;

import com.nbsaas.boot.data.data.entity.QueryReport;
import com.nbsaas.boot.data.api.domain.simple.QueryReportSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* -列表对象转换器
*/

public class QueryReportSimpleConvert implements Converter<QueryReportSimple, QueryReport> {




@Override
public QueryReportSimple convert(QueryReport source) {
    QueryReportSimple result = new QueryReportSimple();

                result.setDataScope6(source.getDataScope6());
                result.setNote(source.getNote());
                result.setHaveFooter(source.getHaveFooter());
                result.setDataScope2(source.getDataScope2());
                result.setDateRange(source.getDateRange());
                result.setDataScope3(source.getDataScope3());
                result.setDebugModel(source.getDebugModel());
                result.setDataScope4(source.getDataScope4());
                result.setDataScope5(source.getDataScope5());

                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setSlowQuery(source.getSlowQuery());
                result.setDataScope1(source.getDataScope1());
                if(source.getType()!=null){
                   Map<Integer,String> TypeMap=new HashMap<>();
                       TypeMap.put(1,"公共查询");
                       TypeMap.put(2,"私有查询");
                   String label=  TypeMap.get(source.getType());
                   result.setTypeName(label);
                }
                result.setType(source.getType());
                result.setContent(source.getContent());
                result.setHeaderStyle(source.getHeaderStyle());
                result.setResultHandleType(source.getResultHandleType());
                result.setId(source.getId());
                result.setClearSql(source.getClearSql());
                result.setSummaryModel(source.getSummaryModel());
                if(source.getExecType()!=null){
                   Map<Integer,String> ExecTypeMap=new HashMap<>();
                       ExecTypeMap.put(1,"执行存储过程");
                       ExecTypeMap.put(2,"不执行存储过程");
                   String label=  ExecTypeMap.get(source.getExecType());
                   result.setExecTypeName(label);
                }
                result.setExecType(source.getExecType());
                result.setLastDate(source.getLastDate());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setPermission(source.getPermission());
                result.setAddDate(source.getAddDate());
                result.setStoreProcedure(source.getStoreProcedure());
                if(source.getDisplayType()!=null){
                   Map<Integer,String> DisplayTypeMap=new HashMap<>();
                       DisplayTypeMap.put(1,"表格");
                       DisplayTypeMap.put(2,"分页");
                   String label=  DisplayTypeMap.get(source.getDisplayType());
                   result.setDisplayTypeName(label);
                }
                result.setDisplayType(source.getDisplayType());
                result.setExtData(source.getExtData());
                result.setResultHandle(source.getResultHandle());
                result.setName(source.getName());
                result.setCacheModel(source.getCacheModel());


    return result;
}

}